package com.andova;

import android.content.Intent;
import android.os.Bundle;
import android.os.Environment;
import android.os.SystemClock;
import android.view.View;
import android.widget.Toast;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

import com.andova.component.AndovaComponentManager;
import com.andova.manager.SharedPreferenceManager;
import com.andova.network.NetworkManager;
import com.andova.sample.R;
import com.andova.toolkit.util.DeviceIdFactory;
import com.tencent.tinker.lib.tinker.TinkerInstaller;

import java.io.File;

/**
 * Created by Administrator on 2018-07-12.
 *
 * @author kzaxil
 * @since 1.0.0
 */
public class MainActivity extends AppCompatActivity {
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.ac_main);
        long id = new DeviceIdFactory(this).getDeviceId();
        System.out.println("id -> " + id);
        new NetworkManager().systemTime("", null);
    }

    public void empty_state(View view) {
        startActivity(new Intent(this, EmptyStateActivity.class));
    }

    public void module_1(View view) {
        startActivity(new Intent(this, Module1Activity.class));
    }

    public void module_2(View view) {
        startActivity(new Intent(this, Module2Activity.class));
    }

    public void baidu_map(View view) {
        startActivity(new Intent(this, BaiDuMapSampleActivity.class));
    }

    public void uploadImage(View view) {
        startActivity(new Intent(this, UploadActivity.class));
    }

    public void toast_Config_Url(View view) {
        Toast.makeText(this, AndovaComponentManager.getInstance().configComponent().getValueOfUrl(), Toast.LENGTH_SHORT).show();
    }

    public void loadPatch(View view) {
        long m = SystemClock.currentThreadTimeMillis();
        System.out.println("boolean a -> " + SharedPreferenceManager.obj().getBooleanA("test"));
        TinkerInstaller.onReceiveUpgradePatch(this, new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS), "patch_signed.apk").getPath());
        System.out.println("millis ->" + (SystemClock.currentThreadTimeMillis() - m));
    }

    public void clearPatch(View view) {
        TinkerInstaller.cleanPatch(this);
    }

    public void timeQuantum(View view) {
        startActivity(new Intent(this, Widget_TimeQuantum.class));
    }
}
